﻿using System;
using System.Text;
using System.Threading;
using System.IO;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;

namespace TCPTest
{
    public class TcpClientSample
    {
        public static void Main()
        {
            Board board = new Board();
            while (true)
            {
                try
                {
                    byte[] data = new byte[1024];
                    string input, stringData;
                    TcpClient server;
                    Parser parser = new Parser();

                    TcpListener tcpListener = new TcpListener(IPAddress.Any, 2013);
                    tcpListener.Start();
                    server = tcpListener.AcceptTcpClient();
                
                    NetworkStream ns = server.GetStream();

                    int numBytesRead;
                    if (server.Available > 0)
                        numBytesRead = ns.Read(data, 0, data.Length);

                    while (true)
                    {
                        Game game = new Game(ns);

                        Console.WriteLine("Disconnecting from server...");
                    }
                    ns.Close();
                    server.Close();

                }
                catch (SocketException)
                {
                    Console.WriteLine("Error");
                    break;
                }
            }
        }
    }
}